#include <iostream>
#include <map>
#include <cmath>

using namespace std;

map<string, int> alwords = {
    {"zero", 0},
    {"one", 1},
    {"two", 2},
    {"three", 3},
    {"four", 4},
    {"five", 5},
    {"six", 6},
    {"seven", 7},
    {"eight", 8},
    {"nine", 9}
};

bool prostch(int n) {
    if (n <= 1) {
        return false;
    }
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    string wordn1, wordn2, wordn3;
    cin >> wordn1 >> wordn2 >> wordn3;

    if (alwords.find(wordn1) == alwords.end() || alwords.find(wordn2) == alwords.end() || alwords.find(wordn3) == alwords.end()) {
        cout << "wrong input" << endl;
        return 0;
    }

    int num = alwords[wordn1] * 100 + alwords[wordn2] * 10 + alwords[wordn3];
    if (num < 100 || num > 999) {
        cout << "wrong input" << endl;
        return 0;
    }
    int a = num;
    while (!prostch(a)) {
        a++;
    }

    cout << a << endl;

    return 0;
}

